{{ template "base.html" .}}

{{ define "body" }}
<div id="home_projects" class="container">
<form action="/delete_project.html" method="POST"
      onsubmit="return confirm('Are you sure you want to delete these projects and all targets/results under this project?')">
      {{ .Csrf_token }}
<table id="project_table" class="table table-bordered table-striped table-hover table-nonfluid">
    <caption><h4>{{ .Labels.title }}</h4></caption>
    <tr>
        <th><input type="checkbox" onClick="toggle(this, 'projects')" /></th>
        <th>{{ .Labels.name }}</th>
        {{ if .Show_descriptions }}
        <th>{{ .Labels.description }}</th>
        {{ end}}
        <th>{{ .Labels.creation_time }}</th>
        <th>{{ .Labels.last_update }}</th>
    </tr>
    {{ range $project := .Projects }}
        <tr>
            <td style="vertical-align:middle"><input type="checkbox" name="projects" value="{{ $project.pk }}" /></td>
            <td style="vertical-align:middle"><a href=" urlfor 'project_sessions' $project.pk ">{{ $project.name }}</a></td>
            {{ if .Show_descriptions }}
            <td style="vertical-align:middle">{{ $project.description }}</td>
            {{ end}}
            <td style="vertical-align:middle">{{ $project.creation_time }}</td>
            <td style="vertical-align:middle">{{ $project.last_update }}</td>
        </tr>
    {{ end}}
</table>
<button class="btn btn-default" type="submit">{{ .Labels.button_delete }}</button>
<a class="btn btn-default" href="/new_project.html">{{ .Labels.button_create }}</a>
</form>
</div>

<script type="text/javascript">
function toggle(source, name) {
    checkboxes = document.getElementsByName(name);
    for(var i=0, n=checkboxes.length; i<n; i++) {
        checkboxes[i].checked = source.checked;
    }
}
</script>

{{ end }}
